﻿@using System.Data

@{
    Layout = null;
    Layout = "~/Areas/Mall/Views/Shared/MallLayout.cshtml";
}

<div class="search">
    <div class="search_l">
        <input type="text" id="s_text" />
    </div>
    <div class="search_r">
        <img src="/Images/seach.jpg" onclick="search()" />
    </div>
</div>
<div class="fl_l">
    <label>热销商品</label>
    <a href="#"></a>
</div>

<div class="goodlist">


</div>
<div style="width: 100%;height: 100px;"></div>
<script>
    var pagecount = 5;
    var pagenum = 0;

    $(window).scroll(function() {
        if ($(document).scrollTop() + $(window).height() >= $(document).height()) {
            pagenum += 1;
            getlist();
        }
    });
    $(function() {
        getlist();
    });
    function getlist() {
        $.post("@Url.Action("GetRxGoodsList")", { pageCount: pagecount, pageIndex: pagenum * pagecount, name: "" }, function (data) {

            var obj = JSON.parse(data);
            var str = "";
            for (var i = 0; i < obj.data.length; i++) {
                var item = obj.data[i];
                str += "<a href=\"/Mall/goods/GoodDetail?gid=" + item.Gid + "\">" +
                    "<img src=\"" + item.Img1 + "\">" +
                    " <label>" + item.Name + " </label><br>" +
                    " <label class=\"goodsprice\">￥" + item.Price + "</label>&nbsp;&nbsp;" +
                    "<label>销量： " + ((parseFloat(item.PayCountTrue)) + (parseFloat(item.PayCount))) + " </label>" +
                    "</a>";
            }
            $(".goodlist").append(str);
        });
    }
    function search() {
        var str = $("#s_text").val();
        if (str == "") {
            alert("请输入商品名称！");
            return false;
        }
        location.href = "@Url.Action("Index","Search")?str=" + encodeURIComponent(str);
    }
</script>